package com.woniu.zsd.order.controller;


import com.woniu.zsd.commons.core.model.Result;
import com.woniu.zsd.order.dto.FindOrderInfoDto;
import com.woniu.zsd.order.from.WorkUpdateWasteFrom;
import com.woniu.zsd.order.service.IOrderWasteService;
import com.woniu.zsd.order.util.TokenUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2025-03-27
 */
@RestController
@Api(tags = "订单废品详情")
@RequestMapping("/order-waste")
public class OrderWasteController {

    @Autowired
    private TokenUtil tokenUtil;
    @Resource
    private IOrderWasteService iOrderWasteService;
    @ApiOperation("工作人员确认废品信息")
    @PostMapping("/workUpdateWaste")
    public Result workUpdateWaste(@RequestBody List<WorkUpdateWasteFrom> wwf, @RequestHeader String token) throws Exception {
        Integer id = tokenUtil.getWorkId(token);
        iOrderWasteService.workUpdateWaste(wwf,id);
        return Result.getResult().setMsg("修改成功");
    }

    @GetMapping("/findOrderInfo")
    @ApiOperation("查询订单废品信息")
    public Result<List<FindOrderInfoDto>> findOrderInfo(String orderNumber){
        List<FindOrderInfoDto> dto = iOrderWasteService.findOrderInfo(orderNumber);
        return Result.getListResult(FindOrderInfoDto.class).setMsg("查询成功").setData(dto);
    }
}
